<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>
    <script src="../js/dayjs.min.js"></script>
</head>
<body>
    <div id="root">
        <h1>{{time | timeTransform | sliceData}}</h1>
        <h2>{{tel | filter_a}}</h2>
    </div>
    <script>
        Vue.config.productionTip = false;

        // 全局过滤器
        Vue.filter("filter_a",(val) => {
            return val.slice(0,3);
        })
        new Vue({
            el: "#root",
            data: {
                time: 1657879227023,
                tel: '18134677670'
            },
            // 局部过滤器
            filters: {
                //  默认将time的值传下来
                timeTransform(val){
                    return dayjs(val).format('YYYY-MM-DD');
                },
                sliceData(val){
                    return val.slice(5,7);
                }
            }
        })
    </script>
</body>
</html>
